home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Demos / A.D. Software / OOFILE / Buildable, limited OOFILE / samples / ooftst18.cpp < prev    next >
C/C++ Source or Header  |  1996-03-23  |  2KB  |  73 lines

  1. // Copyright 1994 A.D. Software. All Rights Reserved
  2.  
  3. // OOFTEST18
  4.  
  5. // This sample tests the wildcard searches.
  6.  
  7. // Simple stream I/O is used to interact with the user.
  8.  
  9. // NOTE the odd sizes in the fields below are to help trap alignment issues
  10.  
  11. #include "oofile.hpp"
  12. #include "ooftst01.inc"
  13.  
  14. int main()
  15. {
  16.     cout << "OOFILE Validation Suite - Test 18\n"
  17.          << "Test of wildcard searching\n";
  18.     
  19.     dbConnect_ctree    theDB;
  20.     dbPeople     People;
  21.  
  22.     theDB.useSeparateFiles();  // note the blank connection names!
  23. // this test creates People.dat, People.idx & Blobs
  24.     
  25. #ifdef _Macintosh
  26. // this feature only on the Mac at present
  27.     #define kExistsName  ":test01:People.dat"
  28.     #define kDatabaseName "test01"
  29. #else
  30.     #define kExistsName "People.dat"
  31.     #define kDatabaseName ""
  32. #endif    
  33.  
  34.     if (dbConnect::fileExists(kExistsName))
  35.         theDB.openConnection(kDatabaseName);
  36.     else {
  37.         theDB.newConnection(kDatabaseName);
  38.         People.AddTestData();
  39.     }
  40.  
  41.     dbView justNames(People);
  42.     justNames << People.LastName << People.OtherNames;
  43.     
  44.     People.setSortOrder(People.LastName);
  45.  
  46.     People.search(People.LastName=="*");
  47.     cout << endl << "Testing pathological case '*' - should be all records" << endl 
  48.          << justNames << endl;
  49.     
  50.     cout << "Retrieving T*r: " << People[People.LastName=="T*r"].LastName << endl;
  51.  
  52.     People.search(People.LastName=="D??t");
  53.     cout << "Listing two D??t records: " << endl << justNames << endl;
  54.  
  55.     People.search(People.LastName=="?mith");
  56.     cout << "Listing leading '?' with ?mith: " << endl << justNames << endl;
  57.  
  58.     People.search(People.LastName=="De*");
  59.     cout << "Listing trailing single '*' with De*: " << endl << justNames << endl;
  60.  
  61.     People.search(People.LastName!="De*");
  62.     cout << "Testing not-equals wildcard with !De*: " << endl << justNames << endl;
  63.  
  64.     People.search(People.LastName.startsWith("D*n"));
  65.     cout << "Listing startsWith D*n: " << endl << justNames << endl;
  66.  
  67.     People.search(People.LastName.startsWith("D*n*"));
  68.     cout << "Listing startsWith D*n*: " << endl << justNames << endl;
  69.  
  70.     cout << "Test Completed" << endl;
  71.     
  72.     return EXIT_SUCCESS;